package cn.shit;

public class JingTaiNeiBu {
    static class Pair {
        private int min;
        private int max;

        Pair(int min, int max) {
            this.min = min;
            this.max = max;
        }

        int getMin() {
            return min;
        }

        int getMax() {
            return max;
        }

        @Override
        public String toString() {
            return "min: " + getMin() + " max: " + getMax();
        }
    }
    public static Pair getMinAndMax(int[] arr) {
        int min = Integer.MAX_VALUE;
        int max = Integer.MIN_VALUE;
        for (int x : arr) {
            if (x > max) {
                max = x;
            }
            if (x < min) {
                min = x;
            }
        }
        return new Pair(min, max);
    }

    public static void main(String[] args) {
        System.out.println(getMinAndMax(new int[]{1, 3, 2, -1, -9, 0}));
    }
}
